package edu.msg.hrappy.api.resource;


import javax.ejb.DependsOn;
import javax.ejb.EJB;
import javax.ejb.LocalBean;
import javax.ejb.Stateless;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;

import edu.msg.hrappy.api.assemblers.JobAssembler;
import edu.msg.hrappy.backend.model.Job;
import edu.msg.hrappy.backend.service.JobService;
import edu.msg.hrappy.backend.service.exception.ServiceException;

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author toroke
 */
@LocalBean
@Stateless
@DependsOn({"JobService", "JobAssembler"})
@Path("/jobs")
@Produces(MediaType.APPLICATION_JSON)
public class JobResource {
    @EJB
    private JobService jobService;
    @EJB
    private JobAssembler jobAssembler;
    
    @Path("/{jobId}")
    @GET
    public Response getJob(@PathParam("jobId") final Long jobId){
        Job job = jobService.getById(jobId);
        try{
            return Response.ok(jobAssembler.modeltoDTO(job)).build();
        }
        catch(final Exception ex){
            //TO DO
        }
		return Response.status(404).build();
    }
}
